import request from '@/utils/request'

enum Api {
  list = '/patrolJobMultiTerminal/loadList',
  save = '/patrolJobMultiTerminal/add',
  edit = '/patrolJobMultiTerminal/edit',
  delOne = '/patrolJobMultiTerminal/delete',
  run = '/patrolJobMultiTerminal/exec'
}

/**
 * 列表
 * @param data
 */
export const list = async (data: {
  pageNum: number
  pageSize: number
  name?: string
  status?: null | string
}) => {
  return await request.post(Api.list, { data })
}

/**
 * 新增
 * @param data
 */
export const save = async (data: {
  name: string
  pointDetailList: Array<[]>
}) => {
  return await request.post(Api.save, { data })
}

/**
 * 编辑
 * @param data
 */
export const edit = async (data: {
  id: string | number
  name: string
  pointDetailList: Array<[]>
}) => {
  return await request.post(Api.edit, { data })
}

/**
 * 删除
 * @param id
 */
export const delOne = async (params: { id: number }) => {
  return await request.delete(Api.delOne, { params })
}

/**
 * 执行
 * @param id
 */
export const run = async (params: { id: number }) => {
  return await request.get(Api.run, { params })
}

/**
 * 巡视点位列表
 * @param
 */
export const getPointList = async () => {
  return await request.get('/patrolJobMultiTerminal/getDevicePointList')
}
